package com.vic.designpattern.patterns.c_behavioral.iterator;

/**
 * @author victor
 */
public class Client {

    public static void main(String[] args) {
        // 抽象聚合
        StudentAggregate aggregate = new StudentAggregateImpl();
        aggregate.addStudent(new Student("张三"));
        aggregate.addStudent(new Student("李四"));
        aggregate.addStudent(new Student("王五"));

        // 迭代器
        StudentIterator studentIterator = aggregate.getStudentIterator();
        while(studentIterator.hasNext()) {
            Student next = studentIterator.next();
            System.out.println(next);
        }

    }


}
